package com.yuan.SMS.controller;

import com.alibaba.fastjson.JSON;
import com.yuan.SMS.bean.Student;
import com.yuan.SMS.dao.StudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@RestController
public class UpdateStudent {
    @Autowired
    StudentDao udao;

    @RequestMapping("/update")
    @CrossOrigin("http://localhost:8080")
    public String updateStudent(Student student){
        int i = udao.updateStudent(student);
        HashMap<String, Object> res = new HashMap<>();
        if(i>0){
            res.put("flag","success");
        }else{
            res.put("flag","error");
        }
        return JSON.toJSONString(res);
    }
}
